<template>
  <!-- 工程案例管理页面组件 -->
  <div class="RootBox">
    <!-- 面包屑导航 -->
    <div class="wanjun">
      <div class="mbnav">
        <div class="mbnavsontwo">
          <!-- 左侧图标 -->
          <el-row class="iconlist">
            <span class="mobile">
              <el-button class="addUser" size="mini" icon="iconfont icon-dingbudaohang-zhangh btnicon" @click="addUser">新建</el-button>
            </span>
            <span class="mobile">
              <el-button size="mini" class="Refresh" icon="iconfont icon-ico_reset btnicon" @click="RefreshUser">刷新</el-button>
            </span>
          </el-row>
          <div class="mobile searchfather">
            <el-input placeholder="标题" clearable v-model="title" class="input-with-select"></el-input>

            <el-button class="search" size="mini" type="primary" @click="serachResult">搜索</el-button>
            <el-button class="search" size="mini" type="primary" @click="resetResult">重置</el-button>
          </div>
        </div>
      </div>
    </div>
    <!-- 树状图加表格 -->
    <div class="tabbleList">
      <!-- 表单结构图 -->
      <div class="fatherform">
        <div class="tableFather">
          <el-table height="540" v-if="tableDatarow" border="" :data="tableDatarow" stripe style="width: 100%" ref="multipleTable" size="mini" :header-cell-style="{ background: '#eff3f8', color: '#606266' }">
            <el-table-column prop="title" label="案例标题"></el-table-column>
            <el-table-column prop="imageUrl" label="案例图片">
              <template slot-scope="{ row }">
                <div>
                  <el-image style="width: 50px; height: 50px" :src="row.imageUrl" error="暂无图片"></el-image>
                </div>
              </template>
            </el-table-column>
            <el-table-column prop="comments" label="描述信息"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <div style="text-align: left">
                  <el-button size="mini" class="updateUser" @click="updateUser(scope.row)">编辑</el-button>
                  <el-button size="mini" type="danger" @click="logoutUser(scope.row)">删除</el-button>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <Pagecomponent :total="total" ref="pagecom" :pagesizelist="[15, 20]" @getAdminRative="pageChange"></Pagecomponent>
      </div>
    </div>
    <updaloadCom @getList="getUserRelease" :routeData="routeData" :show.sync="showUserDialog" :editUserId="editUserId" />
  </div>
</template>
<script>
import Pagecomponent from '@/components/custom/PageCom.vue'
import updaloadCom from './components/dialog.vue'
import authorityApi from '@/utils/tools/authorityApi/index.js'

export default {
  name: 'templateList',
  components: {
    updaloadCom,

    Pagecomponent
  },
  data() {
    return {
      input: '', //修改密码输入框
      dialogVisibleUser: false, //修改密码弹框
      editUserId: '',
      userIsEdit: false,
      showUserDialog: false,

      value: true,
      defaulitOpenList: [], //树形节点记录节点状态
      organizeId: '', //当前选中机构id
      dialogFormVisible: false,
      getUserList: [], // 获取到的树状结构数组
      // falg: true, //默认复选框隐藏
      // 表格数组
      tableDatarow: [],
      // 表单数组
      tableData: [],
      formLabelWidth: '120px',
      //   行政级别下拉数据
      options: [],
      // 上级机构级别
      optionslist: [],
      value1: '',

      dialogVisible: false,
      currentPage: 1,
      total: 0, //总数
      pageSize: 15, //每页显示多少条
      tablerow: [], //当前选中行
      title: '', //名称查询
      organizationName: '', //名称查询
      linkUserName: '', //名称查询
      routeData: {
        // 0工程 1财税 2法律
        sysType: '',
        //0业绩展示 1荣耀资质 2专家团队
        type: ''
      }
    }
  },

  created() {
    this.routeData = {
      sysType: this.$route.meta.fatherType,
      type: this.$route.meta.type
    }
    this.getUserRelease()
    // this.dialogbtnhandle(true)
    console.log(this.$route.meta)
  },
  methods: {
    // 获取工程案例管理页面数据
    getUserRelease(list) {
      if (list && list.length > 0) {
        this.pageSize = list[0]
        this.currentPage = list[1]
      }
      let data = {

        title: this.title || '',
        organizationName: this.organizationName || '',
        pageSize: this.pageSize || list[0],
        currentPage: this.currentPage || list[1],
        ...this.routeData
      }
      authorityApi.bsCardImageApi.pagebsCardImageApi(data, (res) => {
        if (res.records === undefined) {
          this.tableDatarow = []
          this.total = 0
        } else {
          this.tableDatarow = res.records
          this.total = res.total
        }
      })
    },

    //新建工程案例
    addUser() {
      this.editUserId = ''
      this.showUserDialog = true
    },
    //编辑工程案例
    updateUser(row) {
      this.editUserId = row.id
      this.showUserDialog = true
    },
    //删除工程案例
    logoutUser(row) {
      if (!row.id && this.tablerow.length === 0) {
        this.$message({
          type: 'error',
          message: '请选中需要删除的数据'
        })
      } else {
        this.$confirm('此操作将删除该工程案例, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          authorityApi.bsCardImageApi.deletebsCardImageApi({ id: row.id, loading: true }, (res) => {
            this.$message({
              type: 'success',
              message: res
            })
            this.getUserRelease()
            this.$refs.pagecom.gobackone()
          })
        })
      }
    },
    //绑定商品
    bindSp(row) {
      //绑定商品
      this.$refs.spDialog.dialogVisible = true
      this.$refs.spDialog.spId = row.id
    },
    //刷新按钮
    RefreshUser() {
      this.getUserRelease()
    },

    //搜索工程案例事件
    serachResult() {
      this.getUserRelease()
    },
    resetResult() {
      this.linkUserName = ''
      this.title = ''
      this.organizationName = ''
      this.getUserRelease()
    },
    pageChange(list){
      console.log(list);
      this.getUserRelease(list)
    },
  }
}
</script>
<style lang="less" scoped>
.RootBox {
  background-color: #fff;
  height: 100%;
}
.iconlist {
  align-items: center;
}
.mbnav {
  background-color: #fff;
  .mbnavson {
    height: 51px;
    margin-left: 24px;
    line-height: 51px;
    border-bottom: 1px solid #4285f4;
  }
  .mbnavsontwo {
    margin-left: 24px;
    line-height: 64px;
    display: flex;
    align-items: center;
  }
  .mobile {
    line-height: 21px;
    margin-right: 25px;
  }
  .el-button--mini {
    font-size: 12px;

    width: 90px;
  }
}
/deep/ .el-breadcrumb__separator[class*='icon'] {
  color: #4285f4;
}
/deep/.el-breadcrumb__inner {
  color: #4285f4 !important;
  font-size: 14px;
}
.tabbleList {
  background-color: #fff;
  height: 100%;
  display: flex;
}
/deep/.el-tree {
  height: 100%;
  width: 354px;
}
/deep/.el-table__row {
  height: 45px;
}
/deep/.el-tree-node__content {
  height: 45px;
  // background-color: red;
}
/deep/.el-tree-node__content:nth-child(add) {
  background-color: red;
}
/deep/.fatheritemlistname > .el-table--scrollable-x .el-table__body-wrapper {
  overflow-x: hidden !important;
}
.itemlistname {
  width: 100%;
  height: 45px;
  position: relative;
  // z-index: 2;
}
.fatheritemlistname {
  border-top: 1px solid #ccc !important;
  background-color: #fff !important;
  width: 354px !important;
  position: relative;
  display: flex;
  padding-top: 3.5px;
  padding-right: 20px;
}
.fatherform {
  width: 100%;
  padding-left: 20px;
  background-color: #fff !important;
}
/deep/.el-table__body {
  width: none !important;
}
/deep/ .el-table__header {
  width: none;
}
/deep/.cell {
  text-align: center;
}
/deep/ .el-dialog__title {
  color: #4285f4;
}
/deep/ .el-dialog {
  width: 75%;
}
/deep/ .el-dialog__header {
  border-bottom: 1px solid #4285f4;
}
/deep/.el-breadcrumb__inner {
  color: #4285f4 !important;
  font-size: 14px;
}
/deep/.el-breadcrumb__inner.is-link {
  color: #4285f4 !important;
  font-size: 14px !important ;
}
.dialog-footer {
  text-align: center;
}
.dialog-footer {
  text-align: center;
}

/deep/ .el-input__inner {
  height: 33px;
}
/deep/ .el-card {
  // width: 40%;
  box-shadow: none !important;
}
.carld {
  width: 100%;
  display: flex;
  justify-content: center;
}
.formbtn {
  display: flex;
  height: 100%;
  margin: 0 30px;
  justify-content: center;
  flex-direction: column;
}
.gangwei {
  margin: 0 0 30px 0 !important;
}
.gangweistyle {
  color: #4285f4;
  font-size: 20px;
  text-align: center;
  font-weight: bold;
}
/deep/.clearfix {
  text-align: center;
}
/deep/.el-card__body {
  height: 400px;
}
.divbox {
  margin-top: 10px;
}
/deep/.is-leaf {
  background-color: none;
}
/deep/.el-table thead {
  background-color: #f6f6f6;
}
.search {
  margin-left: 24px;
}
.searchfather {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.input-with-select {
  margin-left: 30px !important;
}
/deep/.el-pagination {
  margin-top: 20px;
  text-align: center;
}
/deep/ .el-pagination .el-pagination__jump .el-input {
  width: 50px !important;
}
/deep/.el-pagination {
  margin-bottom: 20px;
}
/deep/.el-select {
  margin-left: 30px;
}
/deep/.input-with-select {
  margin: 0;
}
/deep/.el-select .el-input .el-select__caret.is-reverse {
  transform: rotateZ(-180deg) translateY(-4px);
}
/deep/.el-select .el-input .el-select__caret {
  color: #c0c4cc;
  font-size: 14px;
  transition: transform 0.3s;
  transform: rotateZ(-90deg);
  /* transform: translateY(-4px); */
  cursor: pointer;
}
/deep/.el-tree .el-tree-node__children .el-tree-node__content {
  background-color: transparent !important;
}
.btnicon {
  font-size: 12px;
}
.addUser {
  background-color: #4285f4;
  color: #fff;
}
.updateUser {
  background-color: #1c84c6;
  color: #fff;
}
.Refresh {
  background-color: #f7a54a;
  color: #fff;
}
</style>
